package henu.others;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import henu.bean.Classbean;
import henu.bean.Teacher;
import henu.util.DbcpPool;

public class myTeacher {
	public String getTeacherName(String tid)
	{
		String sql = null;
		sql = "select * from teacher where tid='"+tid+"'";
		ResultSet rs = null;
        String sb = "";
		try{
			rs = DbcpPool.executeQuery(sql);
			while(rs.next()){
			sb = rs.getString("tname");
			}
			rs.close();
		}catch(Exception e)
		{
			e.printStackTrace();
		}
		DbcpPool.close();
		return sb;
	}
	
	
	public List<Teacher> getTeacher() {
		String sql = null;
		sql = "select * from teacher";
		List<Teacher> list = new ArrayList<Teacher>();
		ResultSet rs = null;
		try{
			rs = DbcpPool.executeQuery(sql);
			while(rs.next()){
				Teacher t = new Teacher();
				t.setTid(rs.getString("tid"));
				t.setTname(rs.getString("tname"));
				list.add(t);
			}
			rs.close();
		}catch(Exception e)
		{
			e.printStackTrace();
		}
		DbcpPool.close();
		return list;
	}
}
